package com.guang.springbootrequestversion;

import com.guang.springbootrequestversion.bean.User;
import com.guang.springbootrequestversion.bean1.Dog;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;


@SpringBootApplication
public class SpringbootOneApplication {

    public static void main(String[] args) {
        // 返回IOC容器
        ConfigurableApplicationContext context = SpringApplication.run(SpringbootOneApplication.class, args);
        User bean = context.getBean(User.class);
        System.out.println(bean); // com.guang.springbootone.bean.User@e8fadb0
        // 测试@Conditional。将@Conditional标注在Dog方法上
        Dog dog = context.getBean(Dog.class);
        System.out.println(dog);
        // 测试，不添加@ImportResource
/*        boolean cc = context.containsBean("cc");
        boolean wj = context.containsBean("wj");
        System.out.println("cc---"+cc); // cc---false
        System.out.println("wj---"+wj); // wj---false*/
        // 添加之后
        boolean cc = context.containsBean("cc");
        boolean wj = context.containsBean("wj");
        System.out.println("cc---"+cc); // cc---true
        System.out.println("wj---"+wj); // wj---true
    }


    /**
     * @Configuration(
     *     proxyBeanMethods = false
     * )
     *
     * 表示的是在配置类中加了@Configuration类中的@Bean方法的，不会走cjlib增强的方法从容器中来获取得到对应的对象
     *
     * 如果是true，那么表示的是会从容器中来获取得到对应的代理对象；使用cglib来进行动态代理。
     *

    @Bean
    public String getString(){
        Women women = getWife();
        return "hello,world";
    }

    @Bean
    public Women getWife(){
        Women women = new Women();
        return women;
    }*/

}
